package com.sc.VenusQueryBeta.presenter.account.daikuan;


import com.hengjun.kingstar.sdk.utils.LogUtils;
import com.sc.VenusQueryBeta.contract.account.daikuan.DaiKuanContract;
import com.sc.VenusQueryBeta.model.account.daikuan.DaiKuanModel;
import com.sc.VenusQueryBeta.model.bean.account.AccountList;
import com.sc.VenusQueryBeta.model.bean.account.AllRoomListBean;
import com.sc.VenusQueryBeta.model.bean.account.CurrencyListBean;

import io.reactivex.functions.Consumer;

/**
 * Created by SC-02 on 2018/9/19.
 * 贷款明细presenter 继承契约类的presenper
 */


public class DaiKuanPresenter extends DaiKuanContract.DaiKuanPresenter{
    @Override
    protected DaiKuanContract.IDaiKuanModel getModel() {
        return DaiKuanModel.newInstance();
    }

    @Override
    public void onStart() {

    }

    /**
     * 实例化对象
     */
    public static DaiKuanPresenter newInstance(){
        return new DaiKuanPresenter();
    }
//
//    /**
//     * 查询厅
//     * @param serverAddress
//     * @param projectName
//     * @param serverPort
//     */
//    @Override
//    public void queryAllRoomList(String serverAddress, String projectName, int serverPort) {
//        if (mRxManager != null&&mIModel!=null) {
//            mRxManager.register(mIModel.queryAllRoomList(serverAddress, projectName, serverPort).subscribe(new Consumer<AllRoomListBean>() {
//                @Override
//                public void accept(AllRoomListBean allRoomListBean) throws Exception {
//                    mIView.showqueryAllRoomList(allRoomListBean);
//                }
//            }, new Consumer<Throwable>() {
//                @Override
//                public void accept(Throwable throwable) throws Exception {
//                    LogUtils.e("Network error." + throwable.getMessage());
////                if (mIView != null)
////                    return;
//                    mIView.showToast("Network error.");
//                    mIView.showNetworkError(throwable);
//                }
//            }));
//        }else {
//
//        }
//    }

//    /**
//     * 查询子户口
//     * @param serverAddress
//     * @param projectName
//     * @param serverPort
//     * @param clientindex
//     * @param roomid
//     * @param roomyear
//     * @param roommonth
//     * @param recognitionValue
//     * @param depositType
//     */
//    @Override
//    public void queryClientReserved02(String serverAddress, String projectName, int serverPort, int clientindex, int roomid, String roomyear, String roommonth, String recognitionValue, String depositType) {
//        if (mRxManager != null&&mIModel!=null) {
//            mRxManager.register(mIModel.queryZiHuList(serverAddress, projectName, serverPort, clientindex, roomid, roomyear,
//                    roommonth, recognitionValue, depositType).subscribe(new Consumer<AccountList>() {
//                @Override
//                public void accept(AccountList accountListBean) throws Exception {
//                    mIView.showZiHuKouList(accountListBean);
//                }
//            }, new Consumer<Throwable>() {
//                @Override
//                public void accept(Throwable throwable) throws Exception {
//                    LogUtils.e("错误" + throwable.getMessage());
////                if (mIView != null)
////                    return;
//                    mIView.showToast("Network error." + throwable.getMessage());
//                    mIView.showNetworkError(throwable);
//                }
//            }));
//        }else {
//
//        }
//    }

    @Override
    public void queryAllCurrencyList(String serverAddress, String projectName, int serverPort) {
        if (mRxManager != null&&mIModel!=null) {
            mRxManager.register(mIModel.queryAllCurrencyList(serverAddress, projectName, serverPort).subscribe(new Consumer<CurrencyListBean>() {
                @Override
                public void accept(CurrencyListBean currencyListBean) throws Exception {
                    mIView.showqueryAllCurrencyList(currencyListBean);
                }
            }, new Consumer<Throwable>() {
                @Override
                public void accept(Throwable throwable) throws Exception {
                    LogUtils.e("Network error." + throwable.getMessage());
//                if (mIView != null)
//                    return;
                    mIView.showToast("Network error.");
                    mIView.showNetworkError(throwable);
                }
            }));
        }else {

        }
    }

    @Override
    public void queryClientReserved02(String serverAddress, String projectName, int serverPort, int clientindex, String roomyear, String roommonth, String recognitionValue, String depositType, String currencynameCN) {
        if (mRxManager != null&&mIModel!=null) {
            mRxManager.register(mIModel.queryZiHuList(serverAddress, projectName, serverPort, clientindex,  roomyear,
                    roommonth, recognitionValue, depositType,currencynameCN).subscribe(new Consumer<AccountList>() {
                @Override
                public void accept(AccountList accountListBean) throws Exception {
                    mIView.showZiHuKouList(accountListBean);
                }
            }, new Consumer<Throwable>() {
                @Override
                public void accept(Throwable throwable) throws Exception {
                    LogUtils.e("错误" + throwable.getMessage());
//                if (mIView != null)
//                    return;
                    mIView.showToast("Network error." + throwable.getMessage());
                    mIView.showNetworkError(throwable);
                }
            }));
        }else {

        }
    }


}
